package com.example.netty;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.nio.charset.StandardCharsets;

/**
 * @Date 2022/10/30
 * @Author Jonathan
 */
public class TestByteBuf {

    private static final Logger log = LoggerFactory.getLogger(TestByteBuf.class);

    public static void main(String[] args) {
        // 获取byteBuff
        ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer(10);

        // 默认的
        ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
        // 往buffer里面写数据
        buffer.writeBytes("aaassss".getBytes(StandardCharsets.UTF_8));
        buffer.writeInt(Integer.MAX_VALUE);
        log.info(buffer.toString());
        // 调试的神器
        log.info(ByteBufUtil.prettyHexDump(buffer));
    }
}
